import Vue from "vue";
import Router from "vue-router";
import Layout from "../layout/index";

Vue.use(Router);

export const constantRouterMap = [
  {
    path: "/login",
    meta: { title: "登录", noCache: true },
    component: resolve => require(["@/views/login"], resolve),
    hidden: true
  },
  {
    path: "/sss",
    // component: (resolve) => require(['@/views/dashboard/LineChart'], resolve),
    component: resolve => require(["@/views/system/menu/index"], resolve),
    hidden: true
  },
  {
    path: "/404",
    component: resolve => require(["@/views/features/404"], resolve),
    hidden: true
  },
  {
    path: "/401",
    component: resolve => require(["@/views/features/401"], resolve),
    hidden: true
  },
  {
    path: "/redirect",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "/redirect/:path*",
        component: resolve => require(["@/views/features/redirect"], resolve)
      }
    ]
  },
  {
    path: "/",
    component: Layout,
    redirect: "/dashboard",
    children: [
      {
        path: "dashboard",
        component: resolve => require(["@/views/home"], resolve),
        name: "Dashboard",
        meta: { title: "首页", icon: "index", affix: true, noCache: true }
      },
      {
        path: "/merchantDetail",
        component: resolve => require(["@/views/merchant/page/merchantDetail"], resolve)
      },
      {
        path: "/memberDetail",
        component: resolve => require(["@/views/personnel/page/memberDetail"], resolve)
      },
      {
        path: "/saleDetail",
        component: resolve => require(["@/views/personnel/page/saleDetail"], resolve)
      },
      {
        path: "/orderDetail",
        component: resolve => require(["@/views/order/page/orderDetail"], resolve)
      },
      {
        path: "/goodsDetail",
        component: resolve => require(["@/views/goods/page/goodsDetail"], resolve)
      },
      {
        path: "/diaryDetail",
        component: resolve => require(["@/views/diary/page/diaryDetail"], resolve)
      },
      {
        path: "/evaluateDetail",
        component: resolve => require(["@/views/common/page/evaluateDetail"], resolve)
      },
    ]
  },
  {
    path: "/user",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "center",
        component: resolve => require(["@/views/system/user/center"], resolve),
        name: "个人中心",
        meta: { title: "个人中心" }
      },
    ]
  }
];

export default new Router({
  mode: "hash",
  // mode: 'history',
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
});
